package com.fh.bean.pulc;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class ResultBody<T> {

    @ApiModelProperty(value = "HTTP状态码")
    private int code; // 状态码
    @ApiModelProperty(value = "错误信息")
    private String message; // 返回消息
    @ApiModelProperty(value = "返回的数据")
    private T data; // 返回数据

    private ResultBody(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResultBody<T> ok(T data){
       return new ResultBody<T>(200,"成功",data);
    }
    public static <T> ResultBody<T> ok(){
        return new ResultBody<T>(200,"成功",null);
    }

    public static <T> ResultBody<T> error(String message){
        return new ResultBody<T>(500,message, null);
    }

    public static <T> ResultBody<T> error(Integer code ,String message){
        return new ResultBody<T>(code,message, null);
    }


}
